'use strict';

const svgCaptcha = require('svg-captcha');
const Controller = require('egg').Controller;

class CommonController extends Controller {
  
  async captcha() {
    const { ctx, service } = this

    const captcha = svgCaptcha.create({
      size: 4,
      fontSize: 50,
      ignoreChars: 'Ooli',
      width: 100,
      height: 40,
      noise: 3,
      color: true,
      background: '#ddd',
    })
    ctx.session.captcha = captcha.text;
    ctx.response.type = 'image/svg+xml';
    ctx.body = captcha.data;
  }
}

module.exports = CommonController